package cz.muni.fi.pa036is.dtoconverters;

import cz.muni.fi.pa036is.dto.CommentFormTO;
import cz.muni.fi.pa036is.dto.CommentGridTO;
import cz.muni.fi.pa036is.entity.Comment;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Shebik
 */
public class CommentConverter {

    private CommentConverter() {
    }

    public static Comment convertToComment(final CommentFormTO commentFormTO) {
        final Comment comment = new Comment();
        comment.setMatchId(commentFormTO.getMatchId());
        comment.setName(commentFormTO.getName());
        comment.setText(commentFormTO.getText());
        return comment;
    }

    public static CommentGridTO convertToCommentGridTO(final Comment comment) {
        final CommentGridTO commentGridTO = new CommentGridTO();
        commentGridTO.setId(comment.getId());
        commentGridTO.setMatchId(comment.getMatchId());
        commentGridTO.setName(comment.getName());
        commentGridTO.setText(comment.getText());
        commentGridTO.setTimestamp(comment.getDate());
        return commentGridTO;
    }

    public static List<CommentGridTO> convertToCommentGridTOList(
            final List<Comment> commentList) {
        final List<CommentGridTO> commentGridTOList = new ArrayList<CommentGridTO>();

        for (final Comment comment : commentList) {
            commentGridTOList.add(convertToCommentGridTO(comment));
        }
        return commentGridTOList;
    }
}